home *** CD-ROM | disk | FTP | other *** search
/ The Games Machine 76 / XENIATGM66.iso / Indiana Jones / Indiana Jones.exe / RESOURCE / PREVIEW.GOB / cog_inf_elevcall.cog < prev    next >
Text File  |  1999-11-15  |  12KB  |  341 lines

  1. # Jones 3D Cog Script
  2. #
  3. # gen_ElevCall.cog
  4. #
  5. # This Cog controls one elevator that can be summoned to any number of floors
  6. # A cog must be placed at each floor to be attached to the call button, the up and down
  7. # buttons, and the elevator.
  8. # You have to manually assign to each cog what floor level it is on.
  9. # Remember that the elevator's first frame is 0 even though your first floor may be one.
  10. #
  11. # [SxC]
  12. #
  13. # (C) 1997 LucasArts Entertainment Co. All Rights Reserved
  14. # ========================================================================================
  15.  
  16.  
  17. symbols
  18.  
  19.     message     startup
  20.     message     activate
  21.     message     arrived
  22.     message     blocked
  23.     message     user0
  24.  
  25.     thing       player                             local
  26.     thing        callbutton                                      //calls elevator to level
  27.     thing        upbutton                                        //sends elevator up
  28.     thing        dnbutton                                        //sends elevator down
  29.                                                                 
  30.     thing        elevator                                        //currently handles only one elevator
  31.     thing       elevatorcap
  32.     
  33.     keyframe    elevanim=inf_elvtr_gears.key        local
  34.     keyframe    elevanimup=inf_elvtr_gearup.key     local
  35.                                                                 
  36.     float        speed=5.0                                       
  37.     float       butspeed=3                                      //sets speed default is 5
  38.     int         floorlevel=0.0                                  //sets floor level for each cog
  39.     int            totalfloors=0.0                                 //lastfloor + 1
  40.                                                                 
  41.     sound       gearplatmove=nub_weight_move_c.wav  local
  42.     sound       gearplatstart=nub_elev_start_c.wav  local
  43.     sound       gearplatstop=nub_elev_stop_c.wav    local
  44.     sound       offbuttonsound=aet_gem_place.wav    local                           
  45.                                            
  46.     int            switch                                local       //check variable for cog internal use
  47.     int            bnosound=0                            local
  48.     int         upsound=0                           local
  49.     int         dnsound=0                           local
  50.     int         elevchan                            local
  51.     int         wepnum=1                            local
  52.     int         lastrand=-1                         local
  53.     int         currand=0                           local
  54.     int         keychan                             local
  55.     int         movechan                            local
  56.     int         startchan                           local
  57.     int         curpos
  58.     int         lastbutton                          local
  59.     int         buttonpush=0                        local
  60.     int         screenit=0                          local
  61.     int         powered                             local 
  62.     int         completecount=0                     local                             
  63.                                                     
  64.     sound       indylineb0=inxj058.wav              local
  65.     sound       indylineb1=inxj059.wav              local
  66.     sound       indylineb2=inxj060.wav              local
  67.     sound       indylineb3=inxj061.wav              local
  68.     sound       indylineb4=inxj090.wav              local
  69.     sound       indylineb5=inxj095.wav              local
  70.     
  71. end
  72.  
  73. # ........................................................................................
  74.  
  75. code
  76.  
  77. startup:
  78.  
  79.     player = GetLocalPlayerThing();
  80.     
  81.     //move switches in and disable elevators
  82.     If (callbutton != -1)
  83.     {
  84.         MoveToFrame(callbutton, 1, 10);
  85.     }    
  86.     
  87.     If (upbutton != -1)
  88.     {
  89.         MoveToFrame(upbutton, 1, 10);
  90.     }
  91.     
  92.     If (dnbutton != -1)
  93.     {
  94.         MovetoFrame(dnbutton, 1, 10);
  95.     }    
  96.     
  97.     powered = 0;
  98.     
  99.     ClearThingFlags(elevator, 0x80000);
  100.     SetCollideType(elevator, 0);
  101.     AISetCutsceneMode(elevator);
  102.     AttachThingToThing(elevatorcap, elevator);
  103.     
  104. return;
  105.  
  106. # ........................................................................................
  107.  
  108. user0:
  109.  
  110.     completecount = completecount + 1;
  111.     if (completecount != 2) return;
  112.     
  113.     //move switches to activatable position
  114.     If (callbutton != -1)
  115.     {
  116.         MoveToFrame(callbutton, 0, 10);
  117.     }    
  118.     
  119.     If (upbutton != -1)
  120.     {
  121.         MoveToFrame(upbutton, 0, 10);
  122.     }
  123.     
  124.     If (dnbutton != -1)
  125.     {
  126.         MovetoFrame(dnbutton, 0, 10);
  127.     }
  128.     
  129.     //remove flag on stop switches
  130.     powered = 1;
  131.  
  132. return;
  133.  
  134. # ........................................................................................
  135.  
  136. activate:
  137.  
  138.     switch = GetSenderRef();
  139.     if (screenit == 1) return;
  140.     
  141.     If (powered == 0)
  142.     {
  143.         screenit = 1;
  144.         StopThing(player);
  145.         SetActorFlags(player, 0x200000);
  146.         StartCutscene(1);
  147.         PlayMode(player, 60, 0);
  148.         Sleep(0.35);
  149.         PlaySoundThing(offbuttonsound, switch, 1, 10, 20, 0x0080);
  150.         Sleep(0.35);
  151.         EndCutscene();
  152.         ClearActorFlags(player, 0x200000);
  153.         screenit=0;
  154.         return;    
  155.     }
  156.     
  157.     if ((switch == callbutton) &&                               //if callbutton is pushed
  158.         (bnosound == 0) &&
  159.         (GetCurItem(player) == 0))
  160.         {
  161.         
  162.             bnosound = 1;
  163.             lastbutton = 2;
  164.             buttonpush = 1;
  165.             StartCutscene(1);
  166.             SetActorFlags(player, 0x200000);
  167.             StopThing(player);
  168.             While(wepnum !=0)
  169.             {
  170.                 wepnum = GetCurWeapon(player);
  171.                 DeselectWeaponWait(player);
  172.                 DeselectWeapon(player);
  173.             }
  174.             PlayMode(player, 60, 0); 
  175.             PlaySoundThing(offbuttonsound, switch, 1, 10, 20, 0x0080);                           // changed from 58
  176.             MoveToFrame(callbutton, 1, butspeed);
  177.             WaitForStop(callbutton);
  178.             EndCutscene();
  179.             ClearActorFlags(player, 0x200000);
  180.             startchan=PlaySoundThing(gearplatstart, elevator, 1, 10, 20, 0x0080);
  181.             WaitForSound(startchan);
  182.             AISetMoveSpeed(elevator, 0.65);
  183.             AISetMoveFrame(elevator, floorlevel);
  184.             keychan = PlayKey(elevator, elevanimup, 2, 0x00, 0);
  185.             movechan = PlaySoundThing(gearplatmove, elevator, 1, 5, 10, 0x0081);
  186.             AIWaitForStop(elevator);
  187.             StopKey(elevator, keychan, 0.2);
  188.             StopSound(movechan, 0);
  189.             PlaySoundThing(gearplatstop, elevator, 1, 10, 20, 0x0080);
  190.             MoveToFrame(callbutton, 0, butspeed);
  191.             bnosound = 0;
  192.             curpos = floorlevel;
  193.             wepnum=1;
  194.         }
  195.         else if ((switch == upbutton) &&                        //if upbutton is pushed
  196.              (floorlevel == curpos) &&
  197.              (curpos < totalfloors) &&
  198.              (upsound == 0) &&
  199.              (GetCurItem(player) == 0))
  200.         {
  201.         
  202.             upsound = 1;
  203.             lastbutton = 1;
  204.             buttonpush=1;
  205.             StopThing(player);
  206.             SetActorFlags(player, 0x200000);
  207.             StartCutscene(1);
  208.             While(wepnum !=0)
  209.             {
  210.                 wepnum = GetCurWeapon(player);
  211.                 DeselectWeaponWait(player);
  212.                 DeselectWeapon(player);
  213.             }
  214.             PlayMode(player, 60, 0);              // changed from 58
  215.             PlaySoundThing(offbuttonsound, switch, 1, 10, 20, 0x0080);
  216.             MoveToFrame(upbutton, 1, butspeed);
  217.             WaitForStop(upbutton);
  218.             EndCutscene();
  219.             ClearActorFlags(player, 0x200000);
  220.              
  221.             startchan=PlaySoundThing(gearplatstart, elevator, 1, 10, 20, 0x0080);
  222.             WaitForSound(startchan);
  223.             AISetMoveSpeed(elevator, 0.65);
  224.             AISetMoveFrame(elevator, (floorlevel+1));
  225.             keychan = PlayKey(elevator, elevanimup, 2, 0x00, 0);
  226.             movechan = PlaySoundThing(gearplatmove, elevator, 1, 5, 10, 0x0081);
  227.             AIWaitForStop(elevator);
  228.             StopKey(elevator, keychan, 0.2);
  229.             StopSound(movechan, 0);
  230.             PlaySoundThing(gearplatstop, elevator, 1, 10, 20, 0x0080);
  231.             upsound = 0;
  232.             wepnum=1;
  233.             MoveToFrame(upbutton, 0, butspeed);
  234.             WaitForStop(upbutton);
  235.         }
  236.         else if ((switch == dnbutton) &&                        //if down button is pushed
  237.              (floorlevel == curpos) &&
  238.              (floorlevel > 0) &&
  239.              (dnsound == 0) &&
  240.              (GetCurItem(player) == 0))
  241.         {
  242.         
  243.             dnsound = 1;
  244.             lastbutton = 0;
  245.             buttonpush=1;
  246.             StopThing(player);
  247.             SetActorFlags(player, 0x200000);
  248.             StartCutscene(1);
  249.             While(wepnum !=0)
  250.             {
  251.             
  252.                wepnum = GetCurWeapon(player);
  253.                DeselectWeaponWait(player);
  254.                DeselectWeapon(player);
  255.                
  256.             }
  257.             PlayMode(player, 60, 0);            // changed from 58
  258.             PlaySoundThing(offbuttonsound, switch, 1, 10, 20, 0x0080);
  259.             MoveToFrame(dnbutton, 1, butspeed);
  260.             WaitForStop(dnbutton);
  261.             EndCutscene();
  262.             ClearActorFlags(player, 0x200000);
  263.             
  264.             startchan=PlaySoundThing(gearplatstart, elevator, 1, 10, 20, 0x0080);
  265.             WaitForSound(startchan);
  266.             AISetMoveSpeed(elevator, 0.65);
  267.             AISetMoveFrame(elevator, (floorlevel-1));
  268.             keychan = PlayKey(elevator, elevanim, 2, 0x00, 0);
  269.             movechan = PlaySoundThing(gearplatmove, elevator, 1, 5, 10, 0x0081);
  270.             AIWaitForStop(elevator);
  271.             StopKey(elevator, keychan, 0.2);
  272.             StopSound(movechan, 0);
  273.             PlaySoundThing(gearplatstop, elevator, 1, 10, 20, 0x0080);
  274.             
  275.             MoveToFrame(dnbutton, 0, butspeed);
  276.             dnsound = 0;
  277.             wepnum = 1;
  278.         }
  279.     
  280.      if ((GetCurItem(player) != 0) && (GetSenderID() == 1))
  281.      {
  282.          StopThing(player);
  283.          SetActorFlags(player, 0x200000);
  284.          StartCutscene(1);
  285.          currand = RandBetween(0, 5);
  286.          While (lastrand == currand)
  287.          {
  288.              currand = RandBetween(0, 5);
  289.          }
  290.          PlayVoice(player, indylineb0[currand], 1, 1);
  291.          lastrand = currand;
  292.          EndCutscene();
  293.          ClearActorFlags(player, 0x200000);
  294.      }     
  295.     
  296. return;
  297.  
  298. # ........................................................................................
  299.  
  300. arrived:
  301.  
  302.     If (powered == 0) return;
  303.     curpos = floorlevel;
  304.     //callbutton
  305.     if ((GetSenderRef() == elevator) && (lastbutton == 2) && (buttonpush == 1))
  306.     {
  307.         curpos = floorlevel;
  308.         buttonpush=0;
  309.     }
  310.  
  311.     //upbutton
  312.     if ((GetSenderRef() == elevator) && (lastbutton == 1) && (buttonpush == 1))
  313.     {
  314.         curpos = floorlevel + 1;
  315.         buttonpush=0;
  316.     }
  317.     
  318.     //downbutton
  319.     if ((GetSenderRef() == elevator) && (lastbutton == 0) && (buttonpush == 1))
  320.     {
  321.         curpos = floorlevel - 1;
  322.         buttonpush=0;
  323.     }
  324.     
  325. return;
  326.  
  327. # ........................................................................................
  328. blocked:
  329.     if ((GetSenderRef() == elevatorcap) && (GetSourceRef() == player))
  330.     {
  331.         DamageThing(player, 1000, 0x80, elevatorcap);
  332.     }
  333.     
  334. return;
  335.  
  336. # ........................................................................................
  337.  
  338. end
  339.  
  340.  
  341.